#ifndef ACTIVITY_STRUCT_HH
#define ACTIVITY_STRUCT_HH 1


#include <string>
#include <iostream>
#include <vector>
#include "otl8.hpp"

static const char*  activity_struct_s = "SELECT ID, NAME, INVOICING, LIMITING_ALLOWANCE, PROJECT_ID FROM ACTIVITY_STRUCT";

static const char*  activity_struct_i = "INSERT INTO ACTIVITY_STRUCT ( ID, NAME, INVOICING, LIMITING_ALLOWANCE, PROJECT_ID )VALUES(:f1<int>, :f2<char[128]>, :f3<bool>, :f4<bool>, :f5<int>)";

static const char* activity_struct_c = "CREATE TABLE ACTIVITY_STRUCT ( ID INTEGER , NAME VARCHAR(128) , INVOICING  , LIMITING_ALLOWANCE  , PROJECT_ID INTEGER )";
class activity_struct
{



public:
activity_struct():_id(0), _name(""), _invoicing(0), _limiting_allowance(0), _project_id(0){_select=activity_struct_s;_insert=activity_struct_i;_create=activity_struct_c;}


activity_struct(int a__id, std::string a__name, bool a__invoicing, bool a__limiting_allowance, int a__project_id):_id(a__id) , _name(a__name) , _invoicing(a__invoicing) , _limiting_allowance(a__limiting_allowance) , _project_id(a__project_id) {_select=activity_struct_s;_insert=activity_struct_i;_create=activity_struct_c;}


int id(){return  _id;}
void set_id(int a__id){ _id = a__id;}


std::string name(){return  _name;}
void set_name(std::string a__name){ _name = a__name;}


bool invoicing(){return  _invoicing;}
void set_invoicing(bool a__invoicing){ _invoicing = a__invoicing;}


bool limiting_allowance(){return  _limiting_allowance;}
void set_limiting_allowance(bool a__limiting_allowance){ _limiting_allowance = a__limiting_allowance;}


int project_id(){return  _project_id;}
void set_project_id(int a__project_id){ _project_id = a__project_id;}


activity_struct & operator=( const activity_struct & x)
{
	_id =  x._id;
	_name =  x._name;
	_invoicing =  x._invoicing;
	_limiting_allowance =  x._limiting_allowance;
	_project_id =  x._project_id;
	return *this;
}


bool operator==( const activity_struct & x)
{
	return 	_id ==  x._id &&
	_name ==  x._name &&
	_invoicing ==  x._invoicing &&
	_limiting_allowance ==  x._limiting_allowance &&
	_project_id ==  x._project_id;
}


friend std::istream& operator >> (std::istream& ist, activity_struct & t)
{
	if (!(ist >> t._id)) return ist;
	if (!(ist >> t._name)) return ist;
	if (!(ist >> t._invoicing)) return ist;
	if (!(ist >> t._limiting_allowance)) return ist;
	if (!(ist >> t._project_id)) return ist;

	return ist;
}

friend std::ostream& operator << (std::ostream& ost, activity_struct & t)
{
	ost << t._id << " ";
	ost << t._name << " ";
	ost << t._invoicing << " ";
	ost << t._limiting_allowance << " ";
	ost << t._project_id << " ";

	return ost;
}

/*
friend otl_stream& operator >> (otl_stream& ist, activity_struct & t)
{
	ist >> t._id;
	ist >> t.buf; t._name=(const char*)t.buf;
	ist >> t._invoicing;
	ist >> t._limiting_allowance;
	ist >> t._project_id;

	return ist;
}

friend otl_stream& operator << (otl_stream& ost, activity_struct & t)
{
	ost << t._id ;
	ost << t._name.c_str() ;
	ost << t._invoicing ;
	ost << t._limiting_allowance ;
	ost << t._project_id ;

	return ost;
}
*/

std::string select_stmt() { return _select; }
std::string insert_stmt() { return _insert; }
std::string create_stmt() { return _create; }


private:

	int	_id;
	std::string	_name;
	bool	_invoicing;
	bool	_limiting_allowance;
	int	_project_id;
	std::string _create;
	std::string _select;
	std::string _insert;
char buf[128];
};
#endif
